$item-size: 90px;
$image-size: 60px;
$label-height: 34px;
$row-height: $image-size + $label-height + $default-half-spacing-unit +
  $default-quarter-spacing-unit;

.trace-grid-single-block {
  max-width: 460px;
  display: flex;
  flex-flow: wrap;
  padding: var(--spacing-quarter-unit);
}

.trace-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  @media (max-width: 860px) {
    grid-template-columns: repeat(2, 1fr);
  }
  &__column {
    text-align: center;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    flex-shrink: 0;
    flex-grow: 0;

    &:nth-of-type(4n + 3) {
      -ms-grid-column: 1;
    }
    &:nth-of-type(4n) {
      -ms-grid-column: 2;
    }
    &:nth-of-type(4n + 1) {
      -ms-grid-column: 3;
    }
    &:nth-of-type(4n + 2) {
      -ms-grid-column: 4;
    }
    &:nth-of-type(3),
    &:nth-of-type(4),
    &:nth-of-type(5),
    &:nth-of-type(6) {
      -ms-grid-row: 2;
    }
    &:nth-of-type(7),
    &:nth-of-type(8),
    &:nth-of-type(9),
    &:nth-of-type(10) {
      -ms-grid-row: 3;
    }

    .trace-item {
      &:nth-of-type(2n + 1) {
        -ms-grid-column: 1;
      }
      &:nth-of-type(2n + 2) {
        -ms-grid-column: 2;
      }
      &:nth-of-type(3),
      &:nth-of-type(4) {
        -ms-grid-row: 2;
      }
      &:nth-of-type(5),
      &:nth-of-type(6) {
        -ms-grid-row: 3;
      }
      &:nth-of-type(7),
      &:nth-of-type(8) {
        -ms-grid-row: 4;
      }
    }

    &:not(:first-of-type) {
      position: relative;
      &::before {
        position: absolute;
        width: 1px;
        border-left: var(--border-light);
        height: 100%;
        top: 0;
        left: 0;
        content: '';
      }

      .trace-grid__column__header {
        position: relative;
        z-index: 99;
      }
    }

    &--double {
      grid-column: span 2;
      flex-grow: 0;

      &:nth-of-type(2n + 1) {
        -ms-grid-column: 1;
      }
      &:nth-of-type(2n + 2) {
        -ms-grid-column: 3;
      }
      &:nth-of-type(5),
      &:nth-of-type(6) {
        -ms-grid-row: 2;
      }
      &:nth-of-type(7),
      &:nth-of-type(8) {
        -ms-grid-row: 3;
      }

      .trace-item {
        &:nth-of-type(4n + 1) {
          -ms-grid-column: 1;
        }
        &:nth-of-type(4n + 2) {
          -ms-grid-column: 2;
        }
        &:nth-of-type(4n + 3) {
          -ms-grid-column: 3;
        }
        &:nth-of-type(4n) {
          -ms-grid-column: 4;
        }
        &:nth-of-type(3),
        &:nth-of-type(4) {
          -ms-grid-row: 1;
        }
        &:nth-of-type(5),
        &:nth-of-type(6),
        &:nth-of-type(7),
        &:nth-of-type(8) {
          -ms-grid-row: 2;
        }
        &:nth-of-type(9),
        &:nth-of-type(10),
        &:nth-of-type(11),
        &:nth-of-type(12) {
          -ms-grid-row: 3;
        }
      }

      .trace-grid__column__items {
        display: grid;
        grid-gap: 0;
        grid-template-columns: repeat(4, 1fr);
      }
    }

    &__items {
      display: grid;
      grid-gap: 0;
      grid-template-columns: repeat(2, $item-size);
      grid-template-rows: repeat(2, $row-height);
      flex-grow: 1;
      width: 100%;
      padding: 0 var(--spacing-half-unit) var(--spacing-half-unit);
    }

    &__header {
      text-transform: capitalize;
      font-weight: var(--font-weight-semibold);
      color: var(--color-text-base);
      text-align: left;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      border-top: var(--border-light);
      width: 100%;
      padding: var(--spacing-half-unit) var(--spacing-base-unit) 0;
      box-sizing: border-box;
    }
  }
}

.trace-item {
  width: $item-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex-grow: 0;
  margin-top: var(--spacing-half-unit);
  color: var(--color-text-base);
  @include trans;
  position: relative;

  &--active {
    .trace-item__image {
      border-color: var(--color-accent);
      border-width: 2px;
      color: var(--color-accent);
    }
  }

  &__actions {
    position: absolute;
    width: calc(100%);
    display: flex;
    flex-direction: column;
    top: 0;
    left: var(--spacing-quarter-unit);
    justify-content: flex-start;
    align-items: flex-end;
    z-index: 99;
    height: $image-size;

    &:hover {
      .trace-item__actions__item {
        transform: translateX(-2px);
        opacity: 1;
        pointer-events: initial;
      }
    }
    &__item {
      transform: translateX(-10px);
      opacity: 0;
      pointer-events: none;
      color: var(--color-text-light);
      &:not(:last-child) {
        margin-bottom: var(--spacing-quarter-unit);
      }
      &:hover {
        color: var(--color-accent);
      }
      @include trans;
      svg {
        display: block;
        width: 16px;
        height: 16px;
        fill: currentColor;
      }
    }
  }

  &:hover {
    cursor: pointer;
    color: var(--color-accent);
    .trace-item__label {
      color: var(--color-accent);
    }
    .trace-item__image {
      border-color: var(--color-accent);
    }
  }
  &__image {
    position: relative;
    z-index: 2;
    border: 1px solid var(--color-border-default);
    width: $image-size;
    height: $image-size;
    border-radius: var(--border-radius);
    background: var(--color-background-top);
    box-shadow: 0 2px 9px transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    @include trans;

    &__svg {
      width: 100%;
      flex-grow: 1;
      padding: var(--spacing-quarter-unit);
    }
    svg {
      display: block;
    }

    img {
      display: block;
      font-size: 10px;
      color: var(--color-text-base);
    }
    &__wrapper {
      width: 100%;
    }
  }
  &__label {
    font-weight: var(--font-weight-semibold);
    width: $item-size * 0.8;
    height: $label-height;
    margin-top: var(--spacing-quarter-unit);
    color: var(--color-text-base);
    text-transform: capitalize;
    font-size: var(--font-size-small);
    text-align: center;
  }
}

.trace-type-select-dropdown__wrapper {
  & > * {
    & > * {
      pointer-events: none;
    }
    &:hover {
      cursor: pointer;
      .Select:not(.is-open) .Select-control {
        border-color: var(--color-border-dark);
      }
    }
  }
}

.trace-type-select-button {
  display: flex;
  align-items: center;
  border: var(--border-default);
  width: 100%;
  height: 36px;
  border-radius: var(--border-radius);
  padding: 0 var(--spacing-quarter-unit);
  &:hover {
    cursor: pointer;
    border-color: var(--color-border-dark);
  }
  &__icon {
    max-width: 20px;
    width: 20px;
    margin-right: var(--spacing-quarter-unit);
    svg {
      max-width: 100%;
      display: block;
      * {
        fill: currentColor;
      }
    }
  }
}
